/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package etherblocks.mods.shooter;

import etherblocks.engine.network.*;
import etherblocks.engine.network.messages.*;
import etherblocks.mods.shooter.messages.*;
import etherblocks.mods.shooter.entitysystem.components.*;
import etherblocks.mods.shooter.entitysystem.systems.*;

/**
 *
 * @author Carl
 */
public class ShooterGameServer extends GameServer{

    public ShooterGameServer(){
        
    }

    @Override
    public void onGameStarted(){
        super.onGameStarted();
        addEntitySystem(new RandomMoveSystem());
        addEntitySystem(new ShotEffectSystem());
        addEntitySystem(new CheckHealthSystem());
        addEntitySystem(new ZombieSpawnSystem());
        for(int i=0;i<20;i++){
            ZombieSpawnSystem.spawn(world.getEntityMap());
        }
    }

    @Override
    public MessageResponse getMessageResponse(int clientID, NetworkMessage receivedMessage){
        MessageResponse messageResponse = super.getMessageResponse(clientID, receivedMessage);
        if(receivedMessage instanceof Message_EntityShot){
            Message_EntityShot message = (Message_EntityShot) receivedMessage;
            world.getEntityMap().setComponent(message.getEntityID(), new ShotComponent());
        }
        else if(receivedMessage instanceof Message_SpawnCommand){
            Message_SpawnCommand message = (Message_SpawnCommand) receivedMessage;
            ZombieSpawnSystem.spawn(world.getEntityMap());
        }
        return messageResponse;
    }
}
